/**
 * 给定一个数字串，分成两半记作a和b
 * 要求a和b均合法且a<b
 * a一直取到b不是0开头为止
 * 再看看a是否小于b即可
 */
#include <bits/stdc++.h>
using namespace std;

#include <bits/extc++.h>
using namespace __gnu_pbds;

using Real = long double;
using llt = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;


string S;

void proc(){
    assert(S[0] != '0');
    int n = S.length();
    if(1 == n) return (void)(cout << "-1\n");

    int k = 1;
    while(k < n and S[k] == '0') ++k;

    if(k == n) return (void)(cout << "-1\n");

    auto a = S.substr(0, k);
    auto b = S.substr(k);
    if(a.length() > b.length()) return (void)(cout << "-1\n");

    llt va = 0;
    for(auto c : a) va = va * 10 + (c - '0');

    llt vb = 0;
    for(auto c : b) vb = vb * 10 + (c - '0');

    if(vb <= va) return (void)(cout << "-1\n");

    cout << a << " " << b << "\n";
}

int main(){
#ifndef ONLINE_JUDGE
    freopen("z.txt", "r", stdin);
#endif
    ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(0);
    int nofkase = 1;
    cin >> nofkase;
    while(nofkase--){
        cin >> S;
        proc();
    }
    return 0;
}